import request from '@neu/biz-core/utils/request'
const baseUrl = '/dcam/api/w/fixedAsset'

export const list = () => {
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export const listkj = (params) => {
  debugger
  return request({
    url: baseUrl,
    method: 'get',
    params
  })
}

export const count = (params) => {
  return request({
    url: baseUrl + '/count',
    method: 'get',
    params
  })
}

export const page = (params) => {
  return request({
    url: baseUrl + '/p',
    params,
    method: 'get'
  })
}

export const pageBind = (params) => {
  return request({
    url: baseUrl + '/p/bind',
    params,
    method: 'get'
  })
}

export const pageNoBind = (params) => {
  return request({
    url: baseUrl + '/p/nobind',
    params,
    method: 'get'
  })
}

export const saveBind = (params) => {
  return request({
    url: baseUrl + '/saveBind',
    params,
    method: 'get'
  })
}

export const deleteBind = (params) => {
  return request({
    url: baseUrl + '/deleteBind',
    params,
    method: 'delete'
  })
}

export const myPage = (params) => {
  return request({
    url: baseUrl + '/me/p',
    params,
    method: 'get'
  })
}

export const lifeByCode = (code) => {
  return request({
    url: baseUrl + '/life/' + code,
    method: 'get'
  })
}

export const create = (data) => {
  return request({
    url: baseUrl,
    data,
    method: 'post'
  })
}

export const remove = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'delete'
  })
}

export const batchRemove = (ids) => {
  return request({
    url: baseUrl + '/batch/' + ids,
    method: 'delete'
  })
}

export const detail = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export const detailByCode = (code) => {
  return request({
    url: baseUrl + '/code/' + code,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: baseUrl + '/' + id,
    data,
    method: 'put'
  })
}

export const exportExcel = (belongs, categories, id) => {
  return (params) => {
    return request({
      url: baseUrl + '/' + belongs + '/' + categories + '/' + id + '/export',
      params,
      method: 'get',
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/octet-stream'
      }
    })
  }
}

export const importExcelUrl = (belongs, categories) => {
  return baseUrl + '/' + belongs + '/' + categories + '/import'
}

export const template = (belongs) => {
  return (params) => {
    return request({
      url: baseUrl + '/template/' + belongs,
      params,
      timeout: 120000,
      method: 'get',
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/octet-stream'
      }
    })
  }
}

export const assetTotalStats = (params) => {
  return request({
    url: baseUrl + '/stats/total',
    method: 'get',
    params
  })
}

// 消耗品模板
export const xhTemplate = (belongs) => {
  return (params) => {
    return request({
      url: baseUrl + '/xh/template/' + belongs,
      params,
      timeout: 120000,
      method: 'get',
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/octet-stream'
      }
    })
  }
}

// 导出消耗品数据
export const xhExportExcel = (belongs, categories, id) => {
  return (params) => {
    return request({
      url: baseUrl + '/xh/' + belongs + '/' + categories + '/' + id + '/export',
      params,
      method: 'get',
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/octet-stream'
      }
    })
  }
}

// 导入消耗品数据
export const xhImportExcelUrl = (belongs, categories) => {
  return baseUrl + '/xh/' + belongs + '/' + categories + '/import'
}

export const assetMoneyStats = (params) => {
  return request({
    url: baseUrl + '/stats/money',
    method: 'get',
    params
  })
}

export const statsByBigType = (belongs) => {
  return request({
    url: baseUrl + '/statsByBigType/' + belongs,
    method: 'get'
  })
}

export const statsByMiddleType = (belongs, params) => {
  return request({
    url: baseUrl + '/statsByMiddleType/' + belongs,
    method: 'get',
    params
  })
}

export const statsByOg = (belongs) => {
  return request({
    url: baseUrl + '/statsByOg/' + belongs,
    method: 'get'
  })
}

export const statsByStatus = (belongs) => {
  return request({
    url: baseUrl + '/statsByStatus/' + belongs,
    method: 'get'
  })
}

export const statsByStorehouse = (belongs) => {
  return request({
    url: baseUrl + '/statsByStorehouse/' + belongs,
    method: 'get'
  })
}

export const userRole = () => {
  return request({
    url: baseUrl + '/user/role',
    method: 'get'
  })
}

export const exportTest = (belongs, categories) => {
  return (params) => {
    return request({
      url: baseUrl + '/test/' + belongs + '/' + categories + '/export',
      method: 'get',
      params,
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/octet-stream'
      }
    })
  }
}

export const markLabelPrinted = (idList) => {
  return request({
    url: baseUrl + '/label/print',
    data: idList,
    method: 'put'
  })
}

export const statsByUserAndCategories = (belongs) => {
  return request({
    url: baseUrl + '/statsByUserAndCategories/' + belongs,
    method: 'get'
  })
}

export const statsByOgAndCategories = (belongs) => {
  return request({
    url: baseUrl + '/statsByOgAndCategories/' + belongs,
    method: 'get'
  })
}

export const statsByMiddleTypeAndStatus = (belongs) => {
  return request({
    url: baseUrl + '/statsByMiddleTypeAndStatus/' + belongs,
    method: 'get'
  })
}

export const statsByBigTypeAndStatus = (belongs) => {
  return request({
    url: baseUrl + '/statsByBigTypeAndStatus/' + belongs,
    method: 'get'
  })
}
